package org.example.sb_api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.sb_api.annotation.RequireLogin;
import org.example.sb_api.common.Result;
import org.example.sb_api.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "城市管理")
@RestController
@RequestMapping("/api/city")
@RequireLogin
public class CityController {

    @Autowired
    private CityService cityService;

    @ApiOperation("获取城市列表")
    @GetMapping("/list")
    public Result getCityList() {
        return cityService.getCityList();
    }

    @ApiOperation("获取定位城市列表")
    @GetMapping("/location/list")
    public Result getLocationCityList() {
        return cityService.getLocationCityList();
    }

    @ApiOperation("获取天气列表")
    @GetMapping("/weather/list")
    public Result getWeatherList(
            @RequestParam(required = false) Long cityId,
            @RequestParam(required = false) String cityName) {
        return cityService.getWeatherList(cityId, cityName);
    }
}
